using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace Elementum
{
    class TitleTransition : Transition
    {
        protected Animation _back;
        float _alpha;
        Vector2 _position = new Vector2(400, 240);

        public TitleTransition(string src,float startAlpha, float endAlpha, int start, int end)
            : base(start, end)
        {
            _back = new Animation(src);
            _back.Alpha = startAlpha;
            _alpha = (endAlpha - startAlpha) / (end - start);
        }

        public TitleTransition(Animation title, Vector2 position, float startAlpha, float endAlpha, int start, int end)
            : base(start, end)
        {
            _position = position;
            _back = title;
            _back.Alpha = startAlpha;
            _alpha = (endAlpha - startAlpha) / (end - start);
        }

        protected override void TransitionDone()
        {
            base.TransitionDone();
            _stage.TransitionList.Remove(this);

        }

        public TitleTransition(string src,Vector2 position, float startAlpha, float endAlpha, int start, int end)
            : base(start, end)
        {
            _position = position;
            _back = new Animation(src);
            _back.Alpha = startAlpha;
            _alpha = (endAlpha - startAlpha) / (end - start);
        }

        protected override void OnTransition()
        {
            _back.Alpha += _alpha;
        }

        public override void OnDraw(SpriteBatch spriteBatch)
        {
            base.OnDraw(spriteBatch);

            spriteBatch.Begin();
            if (_counter >= _start && _counter <= _end)
                _back.OnDraw(spriteBatch, _position);
            spriteBatch.End();
        }

    }
}
